﻿/* 获取CPU时钟周期的类
 */

/*待测试*/
namespace LSLib.Threading
{
    using System;

    /// <summary>获取CPU时钟周期的类
    /// </summary>
    public static class CPUCycleCls
    {
        /// <summary>获取CPU时钟周期
        /// </summary>
        /// <returns>当前线程的时钟周期</returns>
        public static ulong GetCycleCount()
        {
            ulong cycleCount = 0;
            API.Threading.QueryThreadCycleTime(API.Threading.GetCurrentThread(), ref cycleCount);
            return cycleCount;
        }

        /// <summary>获取CPU时钟周期
        /// </summary>
        /// <param name="threadHandle">线程的句柄</param>
        /// <returns>指定线程的时钟周期</returns>
        public static ulong GetCycleCount(IntPtr threadHandle)
        {
            ulong cycleCount = 0;
            API.Threading.QueryThreadCycleTime(threadHandle, ref cycleCount);
            return cycleCount;
        }
    }


}
